//
//  Book.swift
//  SLQuickReader
//
//  Created by ALin on 2017/8/10.
//  Copyright © 2017年 ALin. All rights reserved.
//

import UIKit
import ObjectMapper
import SwiftyJSON

class Book: Mappable {
    var id: String?
    /// 书名
    var title: String?
    /// 作者
    var author: String?
    /// 简介
    var shortIntro: String?
    /// 封面图片
    var cover: String?
    private var _latelyFollower: Float = 0.0
    /// 热度
    var latelyFollower: Float{
        set{
            _latelyFollower = newValue
        }
        
        get{
            return _latelyFollower / 10000.0;
        }
    }
    /// 存留率
    var retentionRatio: String?
    
    required init?(jsonData: JSON) {
        self.id = jsonData["_id"].string
        self.title = jsonData["title"].string
        self.author = jsonData["author"].string ?? "作者不详"
        self.shortIntro = jsonData["shortIntro"].string
        self.cover = jsonData["cover"].string
        self.latelyFollower = jsonData["latelyFollower"].float ?? 0
        self.retentionRatio = jsonData["retentionRatio"].string ?? "30.0"
    }
}
